package com.a0soft.gphone.aTruffleHog.wnd.stat;

import com.a0soft.gphone.aTruffleHog.R;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;

public class FindDevicesByCameraPager extends BaseViewPager {
    private String[] m_strTitles;
    
    ////////////////////////////////////////
    @Override protected int
    GetViewPagerID()
    {
        return VIEW_PAGER_FIND_BY_CAMERA_ID;
    }
    
    @Override protected String[] 
    GetTitles(Context ctx)
    {
        if (m_strTitles == null) {
            m_strTitles = new String[2];
            m_strTitles[0] = ctx.getString(R.string.find_device);
            m_strTitles[1] = ctx.getString(R.string.matched_result);
        }
        return m_strTitles;
    }

    @Override protected Fragment 
    GetPage(Context ctx, int nPos)
    {
        if (nPos == 0)
            return FindDevicesByCameraFormFrg.NewInstance();
        else {
            return FindDevicesByCameraFrg.NewInstance();
        }
    }
    
    public boolean
    BackToFirstPage()
    {
        if (m_pager.getCurrentItem() != 0) {
            m_pager.setCurrentItem(0, true);
            return true;
        }
        
        return false;
    }
    
    public void
    FindDevices(FragmentActivity activity, int nMinPixels, int nMaxPixels)
    {
        final int nPage = 1;  
        
        FindDevicesByCameraFrg frg = (FindDevicesByCameraFrg)FindFragmentByPos(activity, nPage);
        if (frg != null) {
            frg.FindDevices(nMinPixels, nMaxPixels);
            //switch to result page
            m_pager.setCurrentItem(nPage, true);
        }        
    }
}
